//为了防止警告：文件名用小写+_,类名用大驼峰
import 'package:flutter/material.dart';

class GoodsDetail extends StatefulWidget {
  const GoodsDetail({super.key});

  @override
  State<GoodsDetail> createState() => _GoodsDetailState();
}

class _GoodsDetailState extends State<GoodsDetail> {
 
  @override
  Widget build(BuildContext context) {
    // 获取路由参数，只能在build里面获取：ModalRoute.of(context)?.settings.arguments
    final params = ModalRoute.of(context)?.settings.arguments as Map<String,dynamic>;
    print(params['name']);
    //只要使用了脚手架包裹就满足路由页面的要求
    return Scaffold(
      appBar: AppBar(
        title: Text('商品详情页'),
        // 取消返回按钮
        automaticallyImplyLeading: false,
      ),
      body: SizedBox(
        child: TextButton(
          onPressed: () {
            Navigator.pop(context);
          },
          child: Text('返回上一页'),
        ),
      ),
    );
  }
}
